<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1"/>
    <title>{$appConfigs.title}</title>
    <link rel="stylesheet" type="text/css" href="{$contextPath}/{$Module.id}/easyui/themes/{$page_theme | default: 'default'}/easyui.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/easyui/css/style.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/style/my.css">
    
    <script type="text/javascript" src="{$contextPath}/pas/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="{$contextPath}/pas/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="{$contextPath}/pas/javascript/my.js"></script>
    
    <script type="text/javascript" src="{$contextPath}/assets/javascript/my.js"></script>
	<script type="text/javascript" src="{$contextPath}/assets/highcharts/highcharts.js"></script>
	<script type="text/javascript" src="{$contextPath}/assets/highcharts/modules/exporting.js"></script>
	<script type="text/javascript" src="{$contextPath}/assets/highcharts/modules/export-data.js"></script>
</head>
<body style="display:inline-block; width:98%;padding:0px">
	<div class="easyui-layout" style="width:99%;height:97%;">
		<div data-options="region:'center',split:true" style="width:75%;">
			<div id="container1" class="easyui-panel" title="投资建议" style="width:98%;padding:0px;"> 
				<table id="dg" class="easyui-datagrid" style="width:99%;"
			            url="/invest/InvestmentSuggestionService/findAll.do?status=0&status=1&rows=10"
			            rownumbers="true" fitColumns="true" singleSelect="true">
			        <thead>
			            <tr>
			                <th field="create_time" formatter="fieldFormatter('create_time')">创建日期</th>
			                <th field="name" formatter="fieldFormatter('name')">名称</th>
			                <th field="transaction_type" formatter="fieldFormatter('transaction_type')">交易类型</th>
			                <th field="amount" formatter="fieldFormatter('amount')">金额</th>
			                <th field="status" formatter="fieldFormatter('suggestion_status')">状态</th>
			                <th field="remarks" formatter="fieldFormatter('remarks')">说明</th>
			                <th field="transaction_date" formatter="fieldFormatter('transaction_date')">交易日期</th>
			            </tr>
			        </thead>
			    </table>
			</div>
			<div id="container0" class="easyui-panel" title="最近交易" style="width:98%;padding:0px;">
				<table id="dg0" class="easyui-datagrid" style="width:99%;"
			            url="/invest/InvestmentTransactionService/findAll.do?rows=10"
			            rownumbers="true" fitColumns="true" singleSelect="true">
			        <thead>
			            <tr>
			                <th field="assetsName" formatter="fieldFormatter('assetsName')">交易产品</th>
			                <th field="transaction_date" formatter="fieldFormatter('transaction_date')">交易日期</th>
			                <th field="status" formatter="fieldFormatter('status')">状态</th>
			                <th field="strategyName" formatter="fieldFormatter('strategyName')">交易策略</th>
			                <th field="transaction_type" formatter="fieldFormatter('transaction_type')">交易类型</th>
			                <th field="transaction_method" formatter="fieldFormatter('transaction_method')">交易方法</th>
			                <th field="quantity" formatter="fieldFormatter('quantity')">交易数量</th>
			                <th field="price" formatter="fieldFormatter('price')">交易价格</th>
			                <th field="amount" formatter="fieldFormatter('amount')">交易金额</th>
			                <th field="remarks" formatter="fieldFormatter('remarks')">说明</th>
			            </tr>
			        </thead>
			    </table>
			</div>
		</div>
		<div data-options="region:'east',split:true" style="width:30%;">
			<div id="p" class="easyui-panel" title="投资品种监控" style="width:100%;padding:2px;">
				<ul id="exps">
				</ul>
			</div>
			<div id="p2" class="easyui-panel" title="投资项目监控" style="width:100%;padding:2px;">
				<ul id="exps2">
				</ul>
			</div>
		</div>
	</div>
	
	<script type="text/javascript">
	var user_id = '{$principal.id}';
	{literal}
	$.getJSON('/invest/HomeMonitorService/getMonitorResult.do?$value=rows', function(data){
		for(var i=0; i< data.length; i++) {
	        $('#exps').append('<li>'+data[i]+'<hr></li> ');
		}
	});
	$.getJSON('/invest/PriceMonitorService/monitor.do?$value=rows&user_id='+user_id, function(data){
		for(var i=0; i< data.length; i++) {
	        $('#exps2').append('<li>'+data[i]+'<hr></li> ');
		}
	});
	
    field_formatters.status=function (value, row, index){
		if(value == 0)
			return '交易中';
		else if(value == 1)
			return "<font color='green'>交易成功</font>";
		else if(value == 2)
			return "<font color='red'>交易失败</font>";
    }
    field_formatters.transaction_type=function (value, row, index){
		if(value == 1)
			return '买入';
		else if(value == -1)
			return '卖出';
    }
    field_formatters.create_time=function (value, row, index){
		if(value)
			return value.substring(0, 10);
    }
    field_formatters.transaction_date=function (value, row, index){
		if(value)
			return value.substring(0, 10);
    }
    field_formatters.transaction_method=function (value, row, index){
		if(value == 0)
			return "<font color='red'>随性交易</font>";
		else if(value == 1)
			return "<font color='blue'>手动交易</font>";
		else if(value == 2)
			return "<font color='green'>策略交易</font>";
		else
			return value;
    }
    field_formatters.objective=function (value, row, index){
		if(value == 0)
			return "无";
		else if(value == 1)
			return "试验仓";
		else if(value == 2)
			return "建仓";
		else if(value == 3)
			return "交易";
		else
			return value;
    }
    field_formatters.suggestion_status=function (value, row, index){
		if(value == 0)
			return '待执行';
		else if(value == 1)
			return '<font color="green">已下单</font>';
		else if(value == 2)
			return '<font color="green">交易成功</font>';
		else if(value == 3)
			return '<font color="red">交易失败</font>';
		else if(value == 4)
			return '<font color="red">取消执行</font>';
    }
    field_formatters.from_date=function (value, row, index){
		if(value)
			return value.substring(0,10);
    }
    field_formatters.to_date=function (value, row, index){
		if(value)
			return value.substring(0,10);
    }
	</script>
	{/literal}
</body>
</html>